package com.bds.btcdc.web.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

import javax.annotation.PostConstruct;
import java.io.File;
import java.math.BigDecimal;

/**
 * Created by guoyu on 2018/1/29.
 */
@Configuration
public class Const {
	@Autowired
	Environment environment;

	/** portal项目域名 */
	// public static final String PORTAL_DOMAIN = "http://localhost:8080";
	public static String PORTAL_DOMAIN;

	public static final String DOMAIN = "www.btcdc.com";

	public static String END_WITH_COUNT="#0.000";//资产情况 金额小数点
	public static final int FAIL = 999;
	public static final int SUC = 200;
	public static final int WARN = 300;

	public final static String sessionKey = "sessionContext";
	public final static String verifyCode = "verifyCode";

	public static final String SESSION_USER = "sessionUser";

	public static final String REDIS_SESSION_HASH_KEY = "user"; // 将登录信息存入redis
	public static final String COOKIES_USER_KEY = "bds_uid"; // 将uid加密后存入cookie（客户端）
	public static final Integer REMEMBERME_TIME = 60 * 60 * 24 * 7;// 密码记住多久 s

	public static final String DESKEY = "12345abc";
	public static String Context;
	public static String Host_Ip;
	public static int Host_Port;
	public static String HttpContext;
	public static String ContextPath = "";

	public static String Zookepper_Nodes;

	public static String Node;
	public static String ZNode;

	public static boolean LOCAL;

	public static final int decimal_num = 4;

	// 文件路径
	public static String FTL_PATH = System.getProperty("user.dir") + File.separator + "ftl";

	public static final String REDIS_IP = "211.152.47.89";

	public static final int REDIS_PORT = 6379;

	public static String WS_URL;
	public static String NODE_URL;

	public static boolean IS_SKIP = false;

	@PostConstruct
	public void doStart() {

		Const.WS_URL = environment.getProperty("ws.url") + "/market_info";
	
		Const.PORTAL_DOMAIN = "http://" + environment.getProperty("portal.url");
		Const.IS_SKIP = environment.getProperty("is.skip", Boolean.class);
		Const.NODE_URL="http://"+environment.getProperty("node.url")+"/TradeService";
	}
	//---------------------------------------策略常量------------start------------------------
	//BigDecimal除法,小数点保留位数
	public static final Integer BDM_SCALE=6;
	//0 吃单判定  1 执行方向 2 涨跌判定 3 回购
	public static final String MSG_TYPE_NAME_ORDER="吃单判定";
	public static final String MSG_TYPE_NAME_DIRECTION="执行方向";
	public static final String MSG_TYPE_NAME_UPDOWN="涨跌判定";
	public static final String MSG_TYPE_NAME_BUYBACK="回购";
	public static final Integer MSG_TYPE_ORDER=0;
	public static final Integer MSG_TYPE_DIRECTION=1;
	public static final Integer MSG_TYPE_UPDOWN=2;
	public static final Integer MSG_TYPE_BUYBACK=3;
	//量化  交易阻塞判定阀值
	public static final Double TRANSACTION_BACKFLOW_ONE=0.2;
	public static final Double TRANSACTION_BACKFLOW_TWO=1.8;
	//量化  寻找最近交易最多的平台(最多的可能不成反比,所以取前3个交易所)
	public static final Integer MAX_EXCHANGES=4;
	//量化  回流 预期收益率阀值
	public static final BigDecimal EXPECT_PROFIT=BigDecimal.ZERO.subtract(BigDecimal.valueOf(0.01));
//---------------------------------------策略常量------------end------------------------


}
